package org.jeecg.modules.htxincailiao.order.domain.vo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.jeecg.modules.htxincailiao.order.entity.HTOrderLibrary;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Iterator;
import java.util.List;

/**
 * @author Administrator 2021-03-26
 * @version V1.0.0
 * @classname CartVO
 * @description description
 */
@Data
public class HTOrderShopVO {
    private static final long serialVersionUID = 1L;

    /**订单店铺ID*/
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "订单店铺ID")
    private String id;
    /**订单父ID*/
    @Excel(name = "订单父ID", width = 15)
    @ApiModelProperty(value = "订单父ID")
    private String orderParentId;
    /**订单ID*/
    @Excel(name = "订单ID", width = 15)
    @ApiModelProperty(value = "订单ID")
    private String orderId;
    /**店铺ID*/
    @Excel(name = "店铺ID", width = 15)
    @ApiModelProperty(value = "店铺ID")
    private String shopId;
    /**下单时店铺名*/
    @Excel(name = "下单时店铺名", width = 15)
    @ApiModelProperty(value = "下单时店铺名")
    private String shopName;
    /**下单时留言*/
    @Excel(name = "下单时留言", width = 15)
    @ApiModelProperty(value = "下单时留言")
    private String leaveMessage;
    /**下单时商品数量店铺小计*/
    @Excel(name = "下单时商品数量店铺小计", width = 15)
    @ApiModelProperty(value = "下单时商品数量店铺小计")
    private Integer subtotalQuantity;
    /**下单时商品金额店铺小计*/
    @Excel(name = "下单时商品金额店铺小计", width = 15)
    @ApiModelProperty(value = "下单时商品金额店铺小计")
    private java.math.BigDecimal subtotalAmount;
    /**下单时优惠金额店铺小计*/
    @Excel(name = "下单时优惠金额店铺小计", width = 15)
    @ApiModelProperty(value = "下单时优惠金额店铺小计")
    private java.math.BigDecimal subtotalDiscountAmount;
    /**按店铺支付金额*/
    @Excel(name = "按店铺支付金额", width = 15)
    @ApiModelProperty(value = "按店铺支付金额")
    private java.math.BigDecimal subtotalPaymentAmount;
    /**运费*/
    @Excel(name = "运费", width = 15)
    @ApiModelProperty(value = "运费")
    private java.math.BigDecimal subtotalFreight;
    /**订单状态：0-待付款、1-待发货、2-待收货、3-已完成、4-已取消*/
    @Excel(name = "订单状态：0-待付款、1-待发货、2-待收货、3-已完成、4-已取消", width = 15)
    @ApiModelProperty(value = "订单状态：0-待付款、1-待发货、2-待收货、3-已完成、4-已取消")
    private Integer orderStatus;
    /**逻辑删除：1表示删除，0表示未删除。*/
    @Excel(name = "逻辑删除：1表示删除，0表示未删除。", width = 15)
    @ApiModelProperty(value = "逻辑删除：1表示删除，0表示未删除。")
    private Integer isDeleted;
    /**创建人*/
    @ApiModelProperty(value = "创建人")
    private String createBy;
    /**创建时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
    private java.util.Date createTime;
    /**更新人*/
    @ApiModelProperty(value = "更新人")
    private String updateBy;
    /**更新时间*/
    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新时间")
    private java.util.Date updateTime;


    /**
     * 多个购物车id
     */
    private String cartIds;


    /**
     * 选中状态
     */
    private boolean checked;

    /**
     * 部分选中
     */
    private boolean checkedIndeterminate;

    /**
     * 购物车集合, 每个店铺商品列表
     */
    private List<HTOrderProductVO> orderProductItems = Lists.newArrayList();




//    public void addToGoodsList(HTOrderGoodsVO goodsVO) {
//        orderProductItems.add(goodsVO);
//    }
//
//    public int update(HTOrderGoodsVO goodsVO) {
//        //修改商品标识,若为0,商品修改时同一商品数量超过100
//        int result = 1;
//        for (HTOrderGoodsVO goodsItem: orderProductItems) {
//            if (goodsItem.getGoodsId().equals(goodsVO.getGoodsId())) {
//                //购物车同一件商品数量不能超过100
//                if (goodsItem.getQuantity() + goodsVO.getQuantity() <= 100) {
//                    goodsItem.setQuantity((goodsItem.getQuantity() + goodsVO.getQuantity()));
//                    result = -2;
//                } else { //商品修改时同一商品数量超过100
//                    result = 0;
//                }
//            }
//        }
//        //判断是否添加
//        if (result == 1) {
//            addToGoodsList(goodsVO);
//        }
//        return result;
//    }
//
//    public void delete(String goodsId) {
//        Iterator<HTOrderGoodsVO> iterator = orderProductItems.iterator();
//        while (iterator.hasNext()) {
//            HTOrderGoodsVO goodsVO = iterator.next();
//            if (goodsVO.getGoodsId() == goodsId) {
//                iterator.remove();
//            }
//        }
//    }

}
